package com.aaa.day04.api;

import com.aaa.utils.MyTool;

import java.text.ParseException;
import java.util.Date;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2024/11/14 9:21
 * @description：
 * @modified By：
 * @version:
 */
public class MyTime {
    public static void main(String[] args) throws ParseException {
        //使用util  date
        Date date = new Date();
       //  Date myDate= new Date(2023,11,11);
        long nowMills = System.currentTimeMillis();
        //获取去年今日的毫秒数
       long lastYearMills=nowMills -(366*24*60*60*1000L);
       Date lastYearDate=new Date(lastYearMills);
        System.out.println(lastYearDate);
        //2024-11-14 9:37:12
       // SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
       /* String format = sdf.format(date);
        System.out.println(format);*/

  /*      String s = MyTool.fromDateToString(date);
        System.out.println(s);*/

        //从字符串转换成date
      /*  Date date1 = sdf.parse("2002-09-28 13:10:10");
        System.out.println(date1);*/
       /* String jp="1945-08-15 12:12:12";
        Date date1 = MyTool.fromStringToDate(jp);
        System.out.println(date1);*/

       /* String jsy="2003-08-12 12:10:10";
        String lly="2002-11-06 12:12:12";
        Date date1 = MyTool.fromStringToDate(jsy);
        Date date2 = MyTool.fromStringToDate(lly);
        //date1是否在date2之后，如果是返回true
        //  boolean after = date1.after(date2);
        boolean before = date1.before(date2);
       // System.out.println(after);
        System.out.println(before);*/

        String jsy="2003-08-12 12:10:10";
        String lly="2002-11-06 12:12:12";
        Date date1 = MyTool.fromStringToDate(jsy);
        Date date2 = MyTool.fromStringToDate(lly);
        long time = date1.getTime();
        System.out.println(time);
    }
}
